import Vue from 'vue';

import http from '@src/util/HttpUtil';
import mtracker from '@src/util/mtracker';

import charts from './index.vue';
import * as echarts5 from 'echarts5';
import echartsConfig from './ShbProject.json'

import onlyNumber from '@src/directive/onlyNumber.js'

// import VueCompositionAPI from 'vue'
import {Cascader} from 'element-ui';

import { isOpenData } from '@src/util/platform';
import platformExtension from '@src/platform/extension';

// Vue.use(VueCompositionAPI);
Vue.use(Cascader);


const install = Vue => {
  Vue.directive('onlyNumber', onlyNumber)
}

if (window.Vue) {
  window['onlyNumber'] = onlyNumber
  Vue.use(install); // eslint-disable-line
}
 
onlyNumber.install = install

Vue.use(onlyNumber); 

echarts5.registerTheme('shb', echartsConfig.theme);
Vue.prototype.$echarts = echarts5;

Vue.prototype.$http = http;
mtracker();

const isQYWX = window.wx || isOpenData

if (isQYWX) {
  platformExtension.sign()
}

// 处理注入的参数
let initData = {};

try {
  initData = typeof window._init == 'string' ? JSON.parse(window._init || '{}') : window._init;
} catch (error) {
  console.warn(error)
  console.warn('no init data')
}

let app = {
  provide: {
    initData: Object.freeze(initData)
  },
  render: h => h(charts)
}

export default app;
